#ifndef LIB_SYSCALL_H
#define LIB_SYSCALL_H

#include "core/syscall.h"
#include "os_cfg.h"
#include <sys/stat.h>
#include "dev/tty.h"

typedef struct _syscall_args_t
{
    int id;
    int arg0;
    int arg1;
    int arg2;
    int arg3;
}syscall_args_t;

void msleep(int ms);
int getpid();
void print_msg(const char* fmt,int arg);
int fork();
int execve(const char* name,char* const *argv,char* const * env);
int yield(void);

int open(const char* name,int flags, ...);
int read(int file,char* ptr,int len);
int write(int file,char* ptr,int len);
int close(int file);
int lseek(int file,int ptr,int dir);
int ioctl(int file,int cmd,int arg0,int arg1);

int unlink(const char* pathname);
int isatty(int file);
int fstat(int file,struct stat * st);
void * sbrk(ptrdiff_t incr);

int dup(int file);

void _exit(int status);
int wait(int * status);

struct dirent
{
    int index;          //表示文件在整个目录中的索引
    int type;           //文件类型目录或者文件
    char name[255];
    int size;
};

//目录
typedef struct _DIR
{
    int index;  //目录中遍历的项的索引
    struct dirent dirent;   //目录中遍历的项
}DIR;

DIR* opendir(const char* path);
struct dirent * readdir(DIR* dir);
int closedir(DIR* dir);

#endif